﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Guang.UserGeolocation.Models;
using Orchard;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Settings;
using Orchard.Localization;
using Guang.UserGeolocation.Settings;
using Guang.UserGeolocation.ViewModels;

namespace Guang.UserGeolocation.Drivers
{
    public class UserCoordinateDriver : ContentPartDriver<UserCoordinatePart>
    {
        
        public UserCoordinateDriver( )
        {
             T = NullLocalizer.Instance;
        }

        public Localizer T { get; set; }

        protected override string Prefix { get { return "UserCoordinatePart"; } }

        protected override DriverResult Display(UserCoordinatePart part, string displayType, dynamic shapeHelper)
        {
            var setting = part.Settings.GetModel<IpinfodbSetting>();
            var model = new UserCoordinateViewModel
            {
                IpinfodbKey = setting.IpinfodbKey
            };
            return ContentShape("Parts_UserCoordinatePart",
                 () => shapeHelper.Parts_UserCoordinatePart(
                         ViewModel: model
                         ));
        }        
    }
}




